Accept proc_macro in addition to proc-macro
authorAlex Crichton <alex@alexcrichton.com>
Wed, 1 Mar 2017 17:22:05 +0000 (09:22 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Wed, 1 Mar 2017 17:22:05 +0000 (09:22 -0800)
More historical behavior...

src/cargo/util/toml.rs

index 8bd6ac6446ba14115e06390ef50c737dd0a70719..277b9610eb1e392bdca234f9062b330ec89027d6 100644 (file)
@@ -988,6 +988,8 @@ struct TomlTarget {
     plugin: Option<bool>,
     #[serde(rename = "proc-macro")]
     proc_macro: Option<bool>,
+    #[serde(rename = "proc_macro")]
+    proc_macro2: Option<bool>,
     harness: Option<bool>,
     #[serde(rename = "required-features")]
     required_features: Option<Vec<String>>,
@@ -1104,12 +1106,16 @@ impl TomlTarget {
         //
         // A plugin requires exporting plugin_registrar so a crate cannot be
         // both at once.
-        if self.plugin == Some(true) && self.proc_macro == Some(true) {
+        if self.plugin == Some(true) && self.proc_macro() == Some(true) {
             Err(human("lib.plugin and lib.proc-macro cannot both be true".to_string()))
         } else {
             Ok(())
         }
     }
+
+    fn proc_macro(&self) -> Option<bool> {
+        self.proc_macro.or(self.proc_macro2)
+    }
 }
 
 impl PathValue {
@@ -1144,7 +1150,7 @@ fn normalize(package_root: &Path,
               .set_doctest(toml.doctest.unwrap_or(t2.doctested()))
               .set_benched(toml.bench.unwrap_or(t2.benched()))
               .set_harness(toml.harness.unwrap_or(t2.harness()))
-              .set_for_host(match (toml.plugin, toml.proc_macro) {
+              .set_for_host(match (toml.plugin, toml.proc_macro()) {
                   (None, None) => t2.for_host(),
                   (Some(true), _) | (_, Some(true)) => true,
                   (Some(false), _) | (_, Some(false)) => false,
@@ -1160,7 +1166,7 @@ fn normalize(package_root: &Path,
             Some(kinds) => kinds.iter().map(|s| LibKind::from_str(s)).collect(),
             None => {
                 vec![ if l.plugin == Some(true) {LibKind::Dylib}
-                      else if l.proc_macro == Some(true) {LibKind::ProcMacro}
+                      else if l.proc_macro() == Some(true) {LibKind::ProcMacro}
                       else {LibKind::Lib} ]
             }
         };